package game.breeze.data;

import game.breeze.math.Position;
import game.breeze.resource.GameObjectDef;
import game.breeze.socket.util.ByteBuffer;

import java.io.Serializable;

public abstract class GameObject implements Serializable {
	private GameObjectDef gameDef;
	protected int id;
	protected String uuid;
	protected String name;
	protected final Position position = new Position();
	/**
	 * 
	 */
	private static final long serialVersionUID = -9193615106901190640L;

	public GameObject(GameObjectDef def) {
		this.gameDef = def;
	}

	public void writeTo(ByteBuffer buffer) {
		buffer.writeUTF(uuid);
		buffer.writeUTF(name);
		buffer.writeInt(position.x);
		buffer.writeInt(position.y);
	}

	/**
	 * @return the gameDef
	 */
	public GameObjectDef getGameDef() {
		return gameDef;
	}

	/**
	 * @param gameDef
	 *            the gameDef to set
	 */
	public void setGameDef(GameObjectDef gameDef) {
		this.gameDef = gameDef;
	}

	/**
	 * @return the uuid
	 */
	public String getUuid() {
		return uuid;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the x
	 */
	public int getX() {
		return position.x;
	}

	/**
	 * @return the y
	 */
	public int getY() {
		return position.y;
	}

	/**
	 * @param uuid
	 *            the uuid to set
	 */
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param x
	 *            the x to set
	 */
	public void setX(int x) {
		this.position.x = x;
	}

	/**
	 * @param y
	 *            the y to set
	 */
	public void setY(int y) {
		this.position.y = y;
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

}
